<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>${appname}</title>
<%@ include file="/WEB-INF/view/common/css_js_ace.jsp"%>
<%@ include file="/WEB-INF/view/common/css_js_ztree.jsp"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script type="text/javascript">
$(function(){
	$('.tipMe').tooltip({'placement':'top'});
	$(".chosen-select").chosen(); 
	$(".profile-info-name").css("width","115px");
});
var lastSelectTable = "";
var tableListSize = ${fn:length(tableInfoList)};

function changeTableInfo(sel){
	var topH = $(parent.document).scrollTop();
	$("#"+lastSelectTable).css("display", "none");
	var currentSelectTable = $(sel).find("option:selected").val();
	$("#"+currentSelectTable).css("display", "");
	lastSelectTable = currentSelectTable;
	$("#tableIndex").html($("#"+currentSelectTable).attr("table_index")+"/"+tableListSize);
	$("#schemaId").html($("#"+currentSelectTable).attr("schema"));
	parent.setIframeHeight(parent.document.getElementById("content"));//设置iframe高度
	$(parent.document).scrollTop(topH);//滚动条定位
}
</script>
<style type="text/css">
.label.arrowed-nn-right:after {
    right: -9.4px;
    border-width: 10px 5px;
}
.chosen-container-single .chosen-search:after {
	display: none;
}
</style>
<body >
	<div class="main-container" id="main-container">
		<div class="main-container-inner">
			<div class="main-content" style="margin-left: 0px;">
				<div class="breadcrumbs" id="breadcrumbs">
					<ul class="breadcrumb">
						<li><i class="icon-home home-icon"></i>首页</li>
						<li>数据源管理 </li>
						<li class="active">数据源查看</li>
					</ul>
				</div>
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
							<div class="widget-box">
					            <div class="widget-header widget-header-flat">
									<div class="widget-toolbar no-border">
									<a class="btn btn-primary btn-xs" href="${ctx}/data_source/data_source_list.do">
										<i class="icon-arrow-left"></i> 返回&nbsp;&nbsp;</a>
									</div>
								</div>
								<div class="widget-body">
									<div class="widget-main">
									    &nbsp;&nbsp;&nbsp;&nbsp;<span class="label label-primary arrowed-right arrowed-nn-right" >数据源基本信息</span>
										<div class="profile-user-info profile-user-info-striped" style="margin-top: 12px;"
											id="taskInfo">
											<div class="profile-info-row" style="height: 45px;">
												<div class="profile-info-name" style="padding-top: 15px;">数据源名称</div>
												<div class="profile-info-value" style="padding-top: 15px;">
													<span class="editable"> ${vo.name } </span>
												</div>
											</div>
											<div class="profile-info-row" style="height: 45px;">
												<div class="profile-info-name" style="padding-top: 15px;">所属节点</div>
												<div class="profile-info-value" style="padding-top: 15px;">
													<span class="editable"> ${vo.nodeName } </span>
												</div>
											</div>
											<div class="profile-info-row" style="height: 45px;">
												<div class="profile-info-name" style="padding-top: 15px;">数据源类型</div>
												<div class="profile-info-value" style="padding-top: 15px;">
													<span class="editable">${app:ctname("DS_TYPE",vo.type)} </span>
												</div>
											</div>
										</div>
										&nbsp;&nbsp;&nbsp;&nbsp;<span class="label label-primary arrowed-right arrowed-nn-right" style="margin-top: 12px;">数据源地址</span>
										<c:if test="${vo.type eq '1'}">
											<div class="profile-user-info profile-user-info-striped" id="taskInfo" style="margin-top: 12px;">
												<div class="profile-info-row" style="height: 45px;">
													<div class="profile-info-name" style="padding-top: 15px;">数据库类型</div>
													<div class="profile-info-value" style="padding-top: 7px;">
														<span class="editable">  ${app:ctname("DB_TYPE",vo.dataSourceConfVo.dbType)} <span
															class="lbl">&nbsp;</span>
														</span>
													</div>
												</div>
												<div class="profile-info-row" style="height: 45px;">
													<div class="profile-info-name" style="padding-top: 15px;">数据库驱动</div>
													<div class="profile-info-value" style="padding-top: 7px;">
														<span class="editable"> ${vo.dataSourceConfVo.driverName} <span
															class="lbl">&nbsp;</span>
														</span>
													</div>
												</div>
												<div class="profile-info-row" style="height: 45px;">
													<div class="profile-info-name" style="padding-top: 15px;">URL</div>
													<div class="profile-info-value" style="padding-top: 7px;">
														<span class="editable"> ${vo.dataSourceConfVo.url} <span
															class="lbl">&nbsp;</span>
														</span>
													</div>
												</div>
													<div class="profile-info-row" style="height: 45px;">
													<div class="profile-info-name" style="padding-top: 15px;">用户名</div>
													<div class="profile-info-value" style="padding-top: 7px;">
														<span class="editable"> ${vo.dataSourceConfVo.userName} <span
															class="lbl">&nbsp;</span>
														</span>
													</div>
												</div>
											</div>	
										</c:if>
										<c:if test="${vo.type eq '2'}">
											<div class="profile-user-info profile-user-info-striped" style="margin-top: 12px;">
												<div class="profile-info-row" style="height: 40px;">
													<div class="profile-info-name" style="padding-top: 10px;">磁盘目录*</div>
													<div class="profile-info-value" style="vertical-align: middle;">
                                                         ${vo.dataSourceConfVo.diskDirectory}
													</div>
												</div>
												<div class="profile-info-row" style="height: 40px;">
													<div class="profile-info-name" style="padding-top: 10px;">是否解析数据内容*</div>
													<div class="profile-info-value" style="vertical-align: middle;">&nbsp;&nbsp;
													     <c:if test="${vo.dataSourceConfVo.ifParseData eq '1'}">
													     	是
													     </c:if>
 													     <c:if test="${vo.dataSourceConfVo.ifParseData eq '0'}">
 													     	否
													     </c:if>
													</div>
												</div>
											</div>
										</c:if>
							            <c:if test="${vo.type eq '1'}">
										&nbsp;&nbsp;&nbsp;&nbsp;<span class="label label-primary arrowed-right arrowed-nn-right" style="margin-top: 12px;">数据源数据结构</span>
											<div id="metadata">
												<div class="row" style="margin-top: 12px;margin-left:12px;">
													<div class="pull-left">
														<select class="pull-left chosen-select" style="width: 200px;" name="tableObject" id="tableObject"
															onchange="changeTableInfo(this)" style="width: 200px;">
															<c:forEach items="${tableInfoList}" var="tableVo">
																<option value="${tableVo.tableName}">${tableVo.tableName}</option>
															</c:forEach>
														</select>
													</div>
													<div class="pull-left" id="tableIndex"
														style="font-size: small; margin-top: 5px;margin-left: 20px;">1/${fn:length(tableInfoList)}</div>
	                                                   <div class="pull-left" style="margin-left: 26px;margin-top: 4px;">
	                                                     <span>schema：<span id="schemaId"></span></span>
	                                                </div>
												</div>
												
	
												<div class="table-responsive" style="margin-top: 5px;margin-left: 12px;margin-right: 12px;">
													<table
														class="table table-striped table-bordered table-hover">
														<thead>
															<tr>
																<th class="center">序号</th>
																<th>项(英文名)</th>
																<th>项(中文名)</th>
																<th>类型</th>
																<th>默认值</th>
																<th>主键/唯一键</th>
																<th>外键表</th>
																<th>外键字段</th>
																<th id="incrementalField_th">增量字段</th>
															</tr>
														</thead>
														<c:forEach items="${tableInfoList}" var="tableInfo"
															varStatus="tablestatus">
															<c:choose>
																<c:when test="${tablestatus.index eq 0}">
																	<tbody id="${tableInfo.tableName}"
																		name="${tableInfo.tableName}"
																		table_index="${tablestatus.index + 1}" schema="${tableInfo.schema}">
																		<script type="text/javascript">
															        	    lastSelectTable = "${tableInfo.tableName}";
															        	    $("#schemaId").html('${tableInfo.schema}');
															            </script>
																</c:when>
																<c:otherwise>
																	<tbody id="${tableInfo.tableName}"
																		name="${tableInfo.tableName}"
																		table_index="${tablestatus.index + 1}" schema="${tableInfo.schema}"
																		style="display: none;">
																</c:otherwise>
															</c:choose>
															<c:forEach items="${tableInfo.tableColVos}" var="colInfo"
																varStatus="status">
																<tr>
																	<td class="center">${status.index + 1}</td>
																	<td>${colInfo.colName }</td>
																	<td><span class="tipMe" title="${colInfo.colComment}">${cm:lmitStrPx(colInfo.colComment,100)}</span></td>
																	<td>${colInfo.colType }</td>
																	<td><span class="tipMe" title="${colInfo.colDefault}">${cm:lmitStrPx(colInfo.colDefault,100)}</span></td>
																	<td class="center"><c:if test="${colInfo.isPk eq 1}">
																		是
																	</c:if></td>
																	<td>${colInfo.fkTableName }</td>
																	<td>${colInfo.fkTablecolName }</td>
																	<td class="center" id="isIc"><c:if
																			test="${colInfo.isIc eq 1}">
																		是										
																	</c:if></td>
																</tr>
															</c:forEach>
															</tbody>
														</c:forEach>
	
													</table>
												</div>
											</div>
										</c:if>	
											
									</div>
								</div>	
						    </div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>